package com.custom.dialogdemo;

import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.custom.dialogdemo.dialog.CommonDialog;
import com.custom.dialogdemo.dialog.DialogHelper;

import java.util.HashMap;
import java.util.Map;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showCitySelect();
            }
        });

    }

    private void showDoubleBtn() {
        final CommonDialog dialog = DialogHelper.getPinterestDialogCancelable(MainActivity.this);
        dialog.getPositiveBt().setTextColor(getResources().getColor(R.color.color_ef7001));
        dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.setMessage("确定提现吗？");
        dialog.setTitle("秀豆提现");
        ImageView iv = new ImageView(MainActivity.this);
        dialog.show();
    }

    private void showCitySelect() {
        // 选择省市区
        // 手工选择城市
        final SelectCtiyDialog select_dialog = new SelectCtiyDialog(
                MainActivity.this);
        select_dialog.showLevel(1);
        select_dialog.showLevel(2);
        select_dialog.showLevel(3);
        select_dialog.setCancelable(true);
        select_dialog.setCanceledOnTouchOutside(true);
        select_dialog
                .setOnPlatformClickListener(new SelectCtiyDialog.OnChangePlatformClick() {
                    @Override
                    public void onPlatformClick(int id) {
                        switch (id) {
                            case R.id.btn_confirm:
//                                String mjson = select_dialog.getJsonValue();
//                                Map<String, String> map = JSON.parseObject(
//                                        mjson, HashMap.class);
//                                String mCurrentProviceName = map
//                                        .get("mCurrentProviceName");
//                                String mCurrentCityName = map
//                                        .get("mCurrentCityName");
//                                String mCurrentDistrictName = map
//                                        .get("mCurrentDistrictName");
//                                String mCurrentZipCode = map
//                                        .get("mCurrentZipCode");
//
//                                setCity(mCurrentProviceName, mCurrentCityName,
//                                        mCurrentDistrictName, mCurrentZipCode);
                                break;
                            default:
                                break;
                        }
                        select_dialog.dismiss();
                    }
                });
        select_dialog.setContentGravity(new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
        select_dialog.show();
    }
}
